/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-10-12
 * Time: 21:16
 */
public class TestH8 {
    public static boolean canJump(int[] num) {
        int left = 0, right = 0, n = num.length;
        int maxIndex = 0;
        while(left <= right) {
            for(int i = left; i <= right; i++) {
                if(maxIndex >= n-1) {
                    return true;
                }
                if(num[i]+i > maxIndex) {
                    maxIndex = num[i]+i;
                }
                left = right+1;
                right = maxIndex;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[] num = {2,3,1,1,4};
        boolean ret = canJump(num);
        System.out.println(ret);
    }
}
